Постройте 95% доверительный интервал для средней годовой смертности в больших городах. Чему равна его нижняя граница? Округлите ответ до 4 знаков после десятичной точки.
In [1]:
import numpy as np
import pandas as pd
In [14]:
data = pd.read_csv('water.txt', header=0, sep='\t')
In [15]:
data.head()
Out[15]:
In [27]:
total_mort = data['mortality']
south_mort = data[data['location']=='South']['mortality']
north_mort = data[data['location']=='North']['mortality']
south_hard = data[data['location']=='South']['hardness']
north_hard = data[data['location']=='North']['hardness']
In [26]:
from statsmodels.stats.weightstats import _zconfint_generic, _tconfint_generic
In [30]:
def get_95_interval(sample):
mean_std = sample.std(ddof=1)/sqrt(len(sample))
return _tconfint_generic(sample.mean(), mean_std, len(sample) - 1, 0.05, 'two-sided')
In [39]:
print get_95_interval(total_mort)
print get_95_interval(south_mort)
print get_95_interval(north_mort)
print get_95_interval(north_hard)
print get_95_interval(south_hard)
In [ ]: